using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TimeCameraWinForm
{
    public partial class Logininformation : Form//后期用于拓展，例如广告，二维码登录
    {
        public Logininformation()
        {
            InitializeComponent();
        }
        public void showGif(string gif,bool close)
      {
          this.Show();
          Bitmap animatedGif = new Bitmap(gif);
          Graphics g = this.panel1.CreateGraphics();
          // A Gif image's frame delays are contained in a byte array
          // in the image's PropertyTagFrameDelay Property Item's
          // value property.
          // Retrieve the byte array...
          int PropertyTagFrameDelay = 0x5100;
          PropertyItem propItem = animatedGif.GetPropertyItem(PropertyTagFrameDelay);
          byte[] bytes = propItem.Value;
          // Get the frame count for the Gif...
          FrameDimension frameDimension = new FrameDimension(animatedGif.FrameDimensionsList[0]);
          int frameCount = animatedGif.GetFrameCount(FrameDimension.Time);
          // Create an array of integers to contain the delays,
          // in hundredths of a second, between each frame in the Gif image.
          int[] delays = new int[frameCount + 1];
          int i = 0;
          for (i = 0; i <= frameCount - 1; i++)
          {
            delays[i] = BitConverter.ToInt32(bytes, i * 4);
          }

      // Play the Gif one time...
          while (!close)
          {
            for (i = 0; i <= animatedGif.GetFrameCount(frameDimension) - 1; i++)
            {
              animatedGif.SelectActiveFrame(frameDimension, i);
              g.DrawImage(animatedGif, new Point(0, 0));
              Application.DoEvents();
              Thread.Sleep(delays[i] * 10);
            }
          }


    }
  }
}
